opendir(DH,"/home/uec-00/yapingli/code/Allele_specific_methylation/") or die;
foreach my $file(readdir(DH)){
	if($file=~/methylCGsRich_ASM_(\w+)Merge_(\w+)_pValue.txt/){
		my $sample=$1;
		my $chr=$2;
		open(FH,"</home/uec-00/yapingli/code/Allele_specific_methylation/$file") or die;
		my @in=<FH>;
		chomp(@in);
		close(FH);
		my @out;
		my $count =0;
		my $total_count = 0;
		foreach my $line(@in){
			my @splitin = split "\t",$line;
			$total_count++;
			if($splitin[2] < 0.05){
				my $start=$splitin[1];
				my $end=$splitin[1]+1;
				$count++;
				push(@out,"$chr\t$sample\texon\t$start\t$end\t0\t\+\t.\n");
			}
		
		}
		print("$sample\t$chr\t$count\t$total_count\n");
		my $out_file="methylCGsRich_ASM_".$sample."Merge_".$chr."_sigGroup.gtf";
		open(OUT,">/home/uec-00/yapingli/code/Allele_specific_methylation/$out_file");
		print OUT @out;
		close(OUT);
		
	}
}